package phoenix.core.data_models.extentions;

import core.ApplicationManager;
import core.data_models.TestDataModel;
import phoenix.core.PhoenixManager;

/**
 * Class provides fields and methods for managing by test model
 */
public class TestDataModelExt extends TestDataModel
{
	// PhoenixManager instance
	protected static PhoenixManager phoenix;

	/**
	 * Initializes TestDataModelExt
	 * @param p_manager ApplicationManager instance
	 * @param p_phoenix PhoenixManager instance
	 */
	public TestDataModelExt(ApplicationManager p_manager, PhoenixManager p_phoenix)
	{
		super(p_manager);
		phoenix = p_phoenix;
	}

	public TestDataModelExt setSiteURL()
	{
		String prefix = "";
		String postfix = ".com";

		if (getSiteName().contains("."))
		{
			postfix = "";
		}
		if (getBuild().equals(phoenix.config().BUILD_LIVE))
		{
			if (getPlatform().equals(phoenix.config().PLATFORM_WEB))
			{
				prefix = "https://www.";
			}
			else if (getPlatform().equals(phoenix.config().PLATFORM_MOBILE))
			{
				prefix = "https://m.";
			}

			setSiteURL(prefix + getSiteName() + postfix);
		}
		else if (getBuild().contains(phoenix.config().BUILD_REL))
		{
			if (getPlatform().equals(phoenix.config().PLATFORM_WEB))
			{
				prefix = "http://www.";
				postfix = "." + manager.testModel().getBuild() + ".platformphoenix.com";
			}
			else if (getPlatform().equals(phoenix.config().PLATFORM_MOBILE))
			{

			}

			setSiteURL(prefix + getSiteName() + postfix);
		}

		return this;
	}
}
